package com.yanqu.road.entity.activity.daomu.skillstrategy.active.impl;

import com.yanqu.road.entity.activity.daomu.DaoMuDamageBuff;
import com.yanqu.road.entity.activity.daomu.enums.DaoMuDamageBuffTypeEnum;
import com.yanqu.road.entity.activity.daomu.param.DaoMuCountSkillHurtReq;
import com.yanqu.road.entity.activity.daomu.enums.DaoMuAttributeEnum;
import com.yanqu.road.entity.activity.daomu.skillstrategy.active.ISkillActiveStrategy;
import com.yanqu.road.entity.activity.daomu.util.DaoMuSkillUtil;

import java.math.BigDecimal;

/**
 * 龙纹斧
 */
public class SkillDragonAxeStrategy implements ISkillActiveStrategy {

    /**
     * 计算技能伤害
     * @param req
     * @return
     */
    @Override
    public long countSkillHurt(DaoMuCountSkillHurtReq req) {
        //技能伤害千分比
        String[] skillParamArr = req.getDaoMuSkillConfig().getSkillPara().split("\\|");
        long mySkillAttRate = Long.parseLong(skillParamArr[1]);
        //攻击方攻击力
        BigDecimal myAttValue = req.getAttributeMap().get(DaoMuAttributeEnum.ATTRIBUTE_ATT.getType()).getValue();
        //攻击方攻击伤害加成千分比
        BigDecimal myHarmAddRate = req.getAttributeMap().get(DaoMuAttributeEnum.ATTRIBUTE_HARM_ADD_RATE.getType()).getValue();
        //攻击方暴击倍数千分表
        BigDecimal myCriticalValue = req.getAttributeMap().get(DaoMuAttributeEnum.ATTRIBUTE_CRITICAL_ATT.getType()).getValue();
        //对方防御力
        BigDecimal targetDefendValue = req.getTargetAttributeMap().get(DaoMuAttributeEnum.ATTRIBUTE_DEFEND.getType()).getValue();
        //对方伤害减免千分比
        BigDecimal targetNotHarmRate = req.getTargetAttributeMap().get(DaoMuAttributeEnum.ATTRIBUTE_NOT_HARM.getType()).getValue();
        //是否暴击
        boolean criticalFlag = req.isCriticalFlag();
        //破甲千分比
        long reDefendRate = 0;
        DaoMuDamageBuff reDefendDamageBuff = req.getDamageBuffMap().get(DaoMuDamageBuffTypeEnum.DAMAGE_BUFF_TYPE_RE_DEFEND.getType());
        if (reDefendDamageBuff != null) {
            reDefendRate = reDefendDamageBuff.getBuffValue();
        }
        //计算最终伤害
        return DaoMuSkillUtil.countSkillHurt(mySkillAttRate, myAttValue, myHarmAddRate, reDefendRate, myCriticalValue, criticalFlag, targetDefendValue, targetNotHarmRate);
    }
}
